﻿<UserControl x:Class="XDCCManager.Controls.ActionList"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
			 xmlns:Actions="clr-namespace:XDCCManager.Model.Actions"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
			 DataContext="{DynamicResource ActionQueueContextDataSource}">
	<UserControl.Resources>
		<DataTemplate x:Key="ProgressDataTemplate">
			<DataTemplate.Resources>
				<Storyboard x:Key="Storyboard1">
					<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="progressBar">
						<DiscreteBooleanKeyFrame KeyTime="0" Value="True"/>
					</BooleanAnimationUsingKeyFrames>
				</Storyboard>
				<Storyboard x:Key="Storyboard2">
					<BooleanAnimationUsingKeyFrames Storyboard.TargetProperty="(ProgressBar.IsIndeterminate)" Storyboard.TargetName="progressBar">
						<DiscreteBooleanKeyFrame KeyTime="0" Value="False"/>
					</BooleanAnimationUsingKeyFrames>
				</Storyboard>
			</DataTemplate.Resources>
			<Grid>
				<ProgressBar x:Name="progressBar" SmallChange="1" LargeChange="10" Value="{Binding Progress}" IsIndeterminate="True"/>
				<TextBlock Text="{Binding Status}" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0,1,0,2"/>
			</Grid>
			<DataTemplate.Triggers>
				<Trigger Property="Value" Value="0" SourceName="progressBar">
					<Trigger.ExitActions>
						<BeginStoryboard Storyboard="{StaticResource Storyboard2}"/>
					</Trigger.ExitActions>
					<Trigger.EnterActions>
						<BeginStoryboard Storyboard="{StaticResource Storyboard1}"/>
					</Trigger.EnterActions>
				</Trigger>
			</DataTemplate.Triggers>
		</DataTemplate>
		<DataTemplate DataType="{x:Type Actions:CreateAction}">
			<StackPanel>
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="Create pack: "/>
					<TextBlock Text="{Binding Change.Description}"/>
				</StackPanel>
				<ContentControl ContentTemplate="{DynamicResource ProgressDataTemplate}" HorizontalContentAlignment="Stretch" Content="{Binding}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate DataType="{x:Type Actions:EditAction}">
			<StackPanel>
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="Edit pack #" d:LayoutOverrides="Width"/>
					<TextBlock Text="{Binding Change.Number}"/>
					<TextBlock Text=":"/>
				</StackPanel>
				<StackPanel Orientation="Horizontal" Margin="10,0,0,0">
					<TextBlock Text="Description: "/>
					<TextBlock Text="{Binding Change.Description}"/>
				</StackPanel>
				<ContentControl ContentTemplate="{DynamicResource ProgressDataTemplate}" HorizontalContentAlignment="Stretch" Content="{Binding}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate DataType="{x:Type Actions:MoveAction}">
			<StackPanel>
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="Move pack: " d:LayoutOverrides="Width"/>
					<TextBlock Text="{Binding Change.Description}"/>
				</StackPanel>
				<StackPanel Orientation="Horizontal" Margin="10,0,0,0">
					<TextBlock Text="From #"/>
					<TextBlock Text="{Binding Change.Source.Number}"/>
					<TextBlock Text=" to #"/>
					<TextBlock Text="{Binding Change.Number}"/>
				</StackPanel>
				<ContentControl ContentTemplate="{DynamicResource ProgressDataTemplate}" HorizontalContentAlignment="Stretch" Content="{Binding}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate DataType="{x:Type Actions:DeleteAction}">
			<StackPanel>
				<StackPanel Orientation="Horizontal">
					<TextBlock Text="Delete pack: " d:LayoutOverrides="Width"/>
					<TextBlock Text="{Binding Change.Description}"/>
				</StackPanel>
				<ContentControl ContentTemplate="{DynamicResource ProgressDataTemplate}" HorizontalContentAlignment="Stretch" Content="{Binding}"/>
			</StackPanel>
		</DataTemplate>
		<DataTemplate DataType="{x:Type Actions:ActionGroup}">
			<StackPanel>
				<ContentControl Content="{Binding FirstAction, Mode=OneWay}" HorizontalContentAlignment="Stretch"/>
				<ItemsControl ItemsSource="{Binding OtherActions, Mode=OneWay}" HorizontalContentAlignment="Stretch" Margin="20,0,0,0"/>
			</StackPanel>
		</DataTemplate>
	</UserControl.Resources>
	<Grid>
		<ItemsControl ItemsSource="{Binding Actions}" HorizontalContentAlignment="Stretch"/>
	</Grid>
</UserControl>
